package com.jotta.client.communicate;



public class PathManager {

    //private static String TAG = "JOTTA_PATHMANAGER";

    private String username;
    private JottaPath jottaPath;


    public JottaPath resetJottaPath(String username) {
        this.username = username;
        jottaPath = new JottaPath(username);
        return jottaPath;
    }

    public JottaPath goHome() {
        jottaPath.goHome();
        return jottaPath;
    }

    public JottaPath reconnectSever(String username, String latestPath) {
        resetJottaPath(username);

        //Log.i(TAG, "latestPath:" + latestPath);
        if (latestPath.equals(new JottaPath(username).getFullPathUnencoded())) {
            goHome();
        }
        return jottaPath;
    }

    public String getCurrentPath() {
        return jottaPath.getFullPathUnencoded();
    }

    public JottaPath getCurrentJottaPath() {
        return jottaPath;
    }

    public String getCurrentFolderName() {
        return jottaPath.getCurrentFolderName();
    }

    public JottaPath goBack() {
        return jottaPath.goBackward();
    }

    public JottaPath goForward(String folderName, boolean isArchiveFolder) {
        if (isArchiveFolder && folderName.equals(Configuration.ARCHIVE_NAME)) {
            jottaPath = new JottaPath(this.username, Configuration.JOTTA_ARCHIVE_PATH);
        } else {
            jottaPath.goForward(folderName);
        }
        return jottaPath;
    }




}
